package reflection;

//测试类什么时候会初始化
public class Test06 {
    static {
        System.out.println("main 类被加载");
    }

    public static void main(String[] args) {
        //1.主动引用
        //Son son = new Son();

        //2.反射也会产生主动引用
//        Son.class;
        /*try {
            Class.forName("reflection.Son");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }*/

        //不会产生类引用
        System.out.println(Son.b);
    }

}
class Father{

    static int b = 2;
    static {
        System.out.println("父类被加载");
    }
}

class Son extends Father{
    static {
        System.out.println("子类被加载");
        m = 300;
    }

    static int m = 100;
    static final int Ma = 1;
}
